package com.oba.king.datalib.productinfo;

import com.oba.base.dao.BaseDao;
import com.oba.base.interfaces.IHsqlBuilder;
import com.oba.king.hospitalinfo.doccolinformation.DoccolCondition;
import com.oba.king.sysmanager.Dept;

public class ProductInfoDao extends BaseDao {

	public IHsqlBuilder buildAll(){
		IHsqlBuilder sql = this.getSqlBuilder("from ProductInfo prdt"); 
		sql.addend("order by prdt.productName");
		return sql;
	}
	
	public IHsqlBuilder buildByCondition(String productName) {
		IHsqlBuilder sql = getSqlBuilder("from ProductInfo pdt");
		sql.add("pdt.productName like ?", productName, "%", "%");
		sql.addend("order by pdt.productName");
		return sql;
	}
	
	// 模糊查询
	public IHsqlBuilder srchProductCondition(ProductCondition productCondition) {
		IHsqlBuilder sql = getSqlBuilder("from ProductInfo prdt");
		sql.add("prdt.productSerialId =?", productCondition.getProductSerialId().trim());
		sql.add("prdt.productName like ?", productCondition.getProductName().trim(), "%", "%");
		sql.add("prdt.productDescription like ?", productCondition.getProductDescription().trim(), "%", "%");
		sql.add("prdt.manufacturer like ?", productCondition.getManufacturer().trim(), "%", "%");
		sql.add("prdt.categoryType =?", productCondition.getCategoryType().trim());
		if(productCondition.getInActive().trim()!=null && !productCondition.getInActive().trim().equals("O")){
			sql.add("prdt.inActive =?", productCondition.getInActive().trim());	
		}				
		sql.addend("order by prdt.productName");
		return sql;
	}
}
